<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    bind函数和call和apply的区别
    <script>
    //     function myBind(that,arg){
    //         let context = this
    //         return function(){
    //             const args = [...arg, ...arguments]   //合并两次传递进来的参数
    //             return context.apply(that,args)
    //         }

    //     }
    //    Function.prototype.myBind = myBind
    //    let obj = {
    //        x:1,
    //        getX:function(){
    //            return this.x
    //        }
    //    }
    //    let hello = obj.getX
    //    console.log(hello())
    //    let newHello = hello.bind(obj)
    //    console.log(newHello)
    function myBind(that,arg){
        let context = this
        return function(){
            let args = [...arg, ...arguments]
            return context.apply(that,args)
        }
    }
    Function.prototype.myBind = myBind
    </script>
</body>
</html>